home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
manchest.lha
/
MANCHESTER
/
manchester
/
4.1
/
go-to-project.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
3KB
|
94 lines
" NAME go-to-project
AUTHOR miw@cs.man.ac.uk (Mario Wolczko)
FUNCTION Uses a menu to navigate the project hierarchy
ST-VERSION 4.1
PREREQUISITES collections-misc
CONFLICTS
DISTRIBUTION world
VERSION 1
DATE 9 Nov 1992
SUMMARY
If you have lots of projects it's a little clumsy getting from one to
the other. This goodies provides a method, Project>selectAndEnter,
that builds a hierarchical menu of projects so that you can jump
around directly. You might want to put this on a launcher menu.
For the labels to be sensible, you must enter and accept some text
into each project.
Mario Wolczko
Dept. of Computer Science Internet: mario@cs.man.ac.uk
The University uucp: mcsun!!ukc!!man.cs!!mario
Manchester M13 9PL JANET: mario@uk.ac.man.cs
U.K. Tel: +44-61-275 6146 (FAX: 6236)
______the mushroom project___________________________________
"
'From Objectworks\Smalltalk(R), Release 4.1 of 15 April 1992 on 9 November 1992 at 9:37:32 pm'!
!Project methodsFor: 'accessing'!
subProjects
"Answer a collection of projects that are directly contained by self."
"Project root subProjects"
^OrderedCollection accumulate: [ :add |
self windows scheduledControllers do:
[:sc || proj |
((proj := sc model) isKindOf: Project)
ifTrue: [add value: proj]]]! !
!Project methodsFor: 'testing'!
hasSubProjects
"Do I have sub-projects?"
^self windows scheduledControllers anySatisfy: [ :sc | sc model isKindOf: Project]! !
!Project class methodsFor: 'viewing'!
labelFor: project
^project value isEmpty
ifTrue: [project holder == project
ifTrue: ['root']
ifFalse: ['unnamed']]
ifFalse: [(project value copyUpTo: Character cr) contractTo: 25]!
popUpMenuFor: project
"Create a menu for project and its subprojects."
| label subProjects labels list |
label := self labelFor: project.
subProjects := project subProjects.
labels := IdentityDictionaryWithDefault newWithDefaultValueBlock: [ :p | self labelFor: p].
list := subProjects asSortedCollection: [ :p1 :p2 | (labels at: p1) <= (labels at: p2)].
^PopUpMenu
labelList:
(Array with: (Array with: label) with: (list collect: [ :p | labels at: p]))
values:
((Array with: project),
(list collect: [ :p |
p hasSubProjects
ifTrue: [self popUpMenuFor: p]
ifFalse: [p]]))!
selectAndEnter
"Project selectAndEnter"
| root proj |
root := self root.
root hasSubProjects
ifFalse: [DialogView warn: 'Only one project!!'. ^self].
proj := (self popUpMenuFor: root) startUp.
proj ~~ 0 ifTrue: [proj enter]! !
!Project class methodsFor: 'constants'!
root
"Return the root project."
| project |
project := Project current.
[project holder == project] whileFalse: [project := project holder].
^project! !